****************************************************************************************
***EXPOSURE TO ONLINE ABUSE OF POLITICIANS DOES NOT SCARE CITIZENS AWAY FROM POLITICS***
****************************************************************************************
****MADE FOR STATA 18*******************************************************************
****************************************************************************************

**************
***Settings***
**************
	*To execute correctly, this do-file requires the packages "estout", "coefplot" and "blindschemes" 
	* ssc install estout //Run this line if "estout" is not already installed (used when creating regression tables)
	* ssc install coefplot //Run this line if "Coefplot" is not already installed (used when plotting results in graphs)
	* ssc install blindschemes //Run this line if "blindschemes is not already installed (used to control graph layout) 
	
	set scheme plotplain
	graph set window fontface "Garamond"
		
************************
***Power calculations***
************************
	 power twomeans 0 0.2, n(1334) 
		
******************************
***Indices and descriptives***
******************************
	
***Creating indices
	*Conflict avoidance 
		tab1 ca_hate_arg ca_con_exc ca_enj_cha ca_arg_dontbother ca_upset
		recode ca_hate_arg ca_con_exc ca_enj_cha ca_arg_dontbother ca_upset (99=.)
		alpha ca_hate_arg ca_con_exc ca_enj_cha ca_arg_dontbother ca_upset, item min(3) gen(uns_conflict_avoidance)
			// The lines below standardize the measure to 0-10 and reverse the direction so high value is high conflict avoidance
			egen uns_conflict_avoidance_min=min(uns_conflict_avoidance) 
			egen uns_conflict_avoidance_max=max(uns_conflict_avoidance)
			gen conflict_avoidance=10*(1-(uns_conflict_avoidance-uns_conflict_avoidance_min)/(uns_conflict_avoidance_max-uns_conflict_avoidance_min))
			drop uns_conflict_avoidance uns_conflict_avoidance_min uns_conflict_avoidance_max 
		tab conflict_avoidance
		label variable conflict_avoidance "Conflict avoidance"
		
	*Prospective political participation 
		tab1 run_election fb_comment fb_share fb_like act_letter_pol act_some_post act_demonstration act_discuss_priv act_letter_news act_petition act_discuss_some vote_municipal
		recode run_election fb_comment fb_share fb_like act_letter_pol act_some_post act_demonstration act_discuss_priv act_letter_news act_petition act_discuss_some vote_municipal (99=.)
		sum run_election fb_comment fb_share fb_like act_letter_pol act_some_post act_demonstration act_discuss_priv act_letter_news act_petition act_discuss_some vote_municipal
		alpha run_election fb_comment fb_share fb_like act_letter_pol act_some_post act_demonstration act_discuss_priv act_letter_news act_petition act_discuss_some vote_municipal, item min(3) gen(political_participation)
		
	*Prospective political participation on social media 
		alpha fb_comment fb_share fb_like act_some_post act_discuss_some, item gen(some_political_participation)
		
	*Prospective political participation outside of social media 
		alpha act_letter_pol act_demonstration act_discuss_priv act_letter_news act_petition vote_municipal, item gen(non_some_political_participation)

*Descriptives	

	*Figure A1: Response distributions on DVs
		hist political_participation,	 		kdensity lcolor(black)	fcolor(white)	percent discrete width(.5) xtitle("") title("Overall Political Participation", box width(150) lpattern(blank)) 
		graph save hist_pp, replace
		hist some_political_participation, 		kdensity lcolor(black)	fcolor(white)	percent discrete width(.5)	xtitle("") title("Social Media Political Participation", box width(150) lpattern(blank))  
		graph save hist_some, replace
		hist non_some_political_participation, 	kdensity lcolor(black)	fcolor(white)	percent discrete width(.5)	xtitle("") title("Non-Social Media Political Participation", box width(150) lpattern(blank))  
		graph save hist_noso, replace
		hist run_election, 						kdensity lcolor(black)	fcolor(white)	percent discrete width(1) xtitle("") title("Run for Office", box width(150) lpattern(blank))  
		graph save hist_run, replace 
		graph combine hist_pp.gph hist_some.gph hist_noso.gph hist_run.gph, col(1) ysize(6) xsize(4)
		graph export hist.tif, replace // This is figure A1 in the online appendix

	tab  completed // Overall attrition rate only 1.0%
	tab random_some_comm completed, chi	// Attrition rate among participants exposed to stimuli only 13/2013=.6%
	tab gender if completed==2
	sum(age) if completed==2
		egen sd_age= sd(age) 
		gen age_sd=age/sd_age
		label variable age_sd "Age"
	recode left_right pol_interest (99=.)
	sum left_right pol_interest conflict_avoidance political_participation some_political_participation non_some_political_participation run_election if completed==2
	
**************		
***Analyses***
**************
	recode react_crit_1 react_crit_2 react_crit_3 react_abuse_1 react_abuse_2 react_abuse_3 (99=.)
	
	gen mergenum=_n
	reshape long mild_cri_ abuse_ react_crit_ react_abuse_ , i(mergenum) j(trial)
		sum react_crit_ react_abuse_	
		tab1 react_crit_ react_abuse
		
		*Figure A2: Reactions to individual comments
		reg react_crit_  i.mild_cri_, cluster(mergenum)
		margins i.mild_cri_, post
		eststo mild_cri_est
		reg react_abuse_  i.abuse_, cluster(mergenum)
		margins i.abuse_ , pwcompare(groups)
		margins i.abuse_, post
		eststo abuse_est
		coefplot 	mild_cri_est abuse_est	, ///
					headings(1.mild_cri_ = "{it: Mildly critical comments}" 1.abuse_ = "{it: Abusive comments}" , labsize(medium)) ///
					coeflabels( ///
					1.abuse_= "Hope I don't see you on the street, because my fists are ready" ///
					2.abuse_= "One can only hope that you will wise up before the election, because you are stupid as shit" ///
					3.abuse_="You deserve an acid bath while your kids watch" ///
					4.abuse_="If you don't shut your mouth we will come and close it for you" ///
					5.abuse_="fuck you, drug whore" ///
					6.abuse_="You and your child deserve to die! Preferably your disgusting offspring first so that you may suffer [...]" ///
					7.abuse_="You should have been an abortion" ///
					8.abuse_="Get some respect for other people, or I'll knock some into your head" ///
					9.abuse_="Wish the same happened to you, you nasty bitch. Denmark would have a better chance of becoming [...]" ///
					10.abuse_= "You have blood on your hands! How does it feel to have stood there like the corrupt satan you are [...] " ///
					11.abuse_= "Please do the world a favor and hang yourself, you fucking whore" ///
					12.abuse_= "I feel like I am going to throw up every time I see you on TV" ///				
					, labsize(small)) legend(off) msymbol(circle) mlcolor(black) mcolor(gs9)  ciopts(color(black)) graphregion(margin(l=-5)) xscale(r(0 10)) xlabel(0(2)10) 	xsize(16) ysize(10)
		graph export react_all_comments.tif, replace // This is figure A2 in the online appendix
		drop  _est_mild_cri_est  _est_abuse_est 
	reshape wide
	
	dtable 	political_participation some_political_participation non_some_political_participation run_election, ///
		by(random_some_comm ) export(descr.docx, replace) // This is Tabel A2 in the online appendix
	
*Hypothesis 1: Exposure to online abuse of politicians decreases citizens' prospective political participation
	reg political_participation 			i.random_some_comm i.gender age_sd pol_interest 
		eststo h1_main
		margins, dydx(i.random_some_comm) post // No significant difference, disconfirming H1
		eststo pp1
	reg some_political_participation		i.random_some_comm i.gender age_sd pol_interest 
		eststo h1_so
		margins, dydx(i.random_some_comm) post // No significant difference, disconfirming H1
		eststo sp1
	reg non_some_political_participation	i.random_some_comm i.gender age_sd pol_interest 
		eststo h1_no
		margins, dydx(i.random_some_comm) post // No significant difference, disconfirming H1
		eststo np1
	reg run_election						i.random_some_comm i.gender age_sd pol_interest 
		eststo h1_run
		margins, dydx(i.random_some_comm) post // No significant difference, disconfirming H1
		eststo rp1
		
		*Exploratory 1 (model without covariates)
		reg political_participation 			i.random_some_comm // Significant difference in opposite direction of H1
			eststo h1_main_exp
		reg some_political_participation		i.random_some_comm 
			eststo h1_so_exp
		reg non_some_political_participation	i.random_some_comm // Significant difference in opposite direction of H1
			eststo h1_no_exp
		reg run_election						i.random_some_comm 
			eststo h1_run_exp	
		

		*Exploratory 2 (model with additional covariates)
		reg political_participation 			i.random_some_comm i.gender age_sd pol_interest left_right conflict_avoidance  
			eststo h1_main_exp2
		reg some_political_participation		i.random_some_comm i.gender age_sd pol_interest left_right conflict_avoidance  
			eststo h1_so_exp2
		reg non_some_political_participation	i.random_some_comm i.gender age_sd pol_interest left_right conflict_avoidance  
			eststo h1_no_exp2
		reg run_election						i.random_some_comm i.gender age_sd pol_interest left_right conflict_avoidance  
			eststo h1_run_exp2	
			
		*Exploratory 3: *Inferiority Tests 
			sum political_participation if completed==2
 			local sd01 = -`r(sd)'/10
			di `sd01'
			estimates restore h1_main
			test 3.random_some_comm=`sd01'
			
			sum some_political_participation if completed==2
 			local sd01 = -`r(sd)'/10
			di `sd01'
			estimates restore h1_so
			test 3.random_some_comm=`sd01'
			
			sum non_some_political_participation if completed==2
 			local sd01 = -`r(sd)'/10
			di `sd01'
			estimates restore h1_no
			test 3.random_some_comm=`sd01'
			
			sum run_election if completed==2
 			local sd01 = -`r(sd)'/10
			di `sd01'
			estimates restore h1_run
			test 3.random_some_comm=`sd01'
			
	*Figure 1: Main effects on political participation (Preregistered)
	coefplot 	(h1_main), bylabel("Overall pol." "participation") msymbol(circle) msize(medlarge) mcolor(gs9)  mlcolor(black) ciopts(recast(rspike) color(black)) || ///
				 h1_so , bylabel("Social media pol." "participation") || ///
				 h1_no , bylabel("non-SoMe pol." "participation")  || ///
				 h1_run , bylabel("Run for" "office") ///
				xline(0)  xscale(r(-1 1)) xlabel(, nogrid) drop(_cons) byopts(compact cols(4) scale(1.5))	xsize(6) ysize(3) coeflabels(, wrap(115) labcolor(black)) ///
				mlabposition(2) mlabgap(0.1pt) ///
				mlabel(cond(@pval<.001, "***", ///
				cond(@pval<.01, "**",   ///
				cond(@pval<.05, "*", "")))) ///
				headings(2.random_some_comm = "{it:Treatments}" 2.gender = "{it:Covariates}" , nogap )  grid(between glpattern(solid) glwidth(vvthin))
				graph export h1.tif, replace // This is Figure 1 in the article	
	
	*Figure A3: Main effects on political participation (Preregistered and exploratory)
	coefplot 	(h1_main, label("Preregistered model")	msymbol(circle) msize(medlarge) mcolor(gs9)  mlcolor(black) ciopts(recast(rspike) color(black) ) )	///
				(h1_main_exp, label("Model without covariates (exploratory)")  msymbol(circle) msize(medlarge) mcolor(gs16)  mlcolor(black) ciopts(recast(rspike) color(black) ) )		///
				(h1_main_exp2, label("Model with additional covariates (exploratory)")  msymbol(circle) msize(medlarge) mcolor(gs0)  mlcolor(black) ciopts(recast(rspike) color(black) ) ), /// 
				bylabel("Overall pol." "participation") || ///
				h1_so h1_so_exp h1_so_exp2, bylabel("Social media pol." "participation") || ///
				h1_no h1_no_exp h1_no_exp2, bylabel("non-SoMe pol." "participation")  || ///
				h1_run h1_run_exp h1_run_exp2, bylabel("Run for" "office") ///
				xline(0) xscale(r(-1 1)) drop(_cons /* age_sd  2.gender pol_interest */) byopts(compact cols(4) scale(1))	xsize(6) ysize(4.5) coeflabels(, wrap(115) labcolor(black)) ///
				mlabposition(2) mlabgap(0.1pt) ///
				mlabel(cond(@pval<.001, "***", ///
				cond(@pval<.01, "**",   ///
				cond(@pval<.05, "*", "")))) ///
				headings(2.random_some_comm = "{it:Treatments}" 2.gender = "{it:Covariates}" ) 
				graph export h1_sup.tif, replace // This is Figure A3 in the online appendix
	
	* Exploratory, individual items
		eststo m1: reg fb_comment 							i.random_some_comm i.gender age_sd pol_interest 
		eststo m2: reg fb_share 							i.random_some_comm i.gender age_sd pol_interest 
		eststo m3: reg fb_like 								i.random_some_comm i.gender age_sd pol_interest 
		eststo m4: reg act_letter_pol 						i.random_some_comm i.gender age_sd pol_interest  // Significant difference in opposite direction of H1
			egen SD = sd(act_letter_pol)	
			display _b[3.random_some_comm] / SD
			drop SD
		eststo m5: reg act_some_post 						i.random_some_comm i.gender age_sd pol_interest // Significant difference in opposite direction of H1
			egen SD = sd(act_some_post)	
			display _b[3.random_some_comm] / SD
			drop SD
		eststo m6: reg act_demonstration 					i.random_some_comm i.gender age_sd pol_interest 
		eststo m7: reg act_discuss_priv 					i.random_some_comm i.gender age_sd pol_interest 
		eststo m8: reg act_letter_news 						i.random_some_comm i.gender age_sd pol_interest // Significant difference in opposite direction of H1
			egen SD = sd(act_letter_news)	
			display _b[3.random_some_comm] / SD
			drop SD
		eststo m9: reg act_petition 						i.random_some_comm i.gender age_sd pol_interest // Significant difference in opposite direction of H1
			egen SD = sd(act_petition)	
			display _b[3.random_some_comm] / SD
			drop SD
		eststo m10: reg act_discuss_some 					i.random_some_comm i.gender age_sd pol_interest 
		eststo m11: reg vote_municipal						i.random_some_comm i.gender age_sd pol_interest 
		eststo m12: reg run_election 						i.random_some_comm i.gender age_sd pol_interest 
				
	*Figure 2: Effects of social media messages across 12 dependent variables (Exploratory)	
			coefplot 	m1, bylabel("Comment on politician's FB post") || m2, bylabel("Share a politician's FB post") || m3, bylabel("Like a politician's FB post") ||m4, bylabel("Write a letter or email to politician") ///
						|| m5, bylabel("Write a social media post") ||m6, bylabel("Demonstrate") || m7, bylabel("Discuss privately") || m8, bylabel("Write letter to newspaper") ///
						|| m9, bylabel("Sign petition") || m10, bylabel("Discuss on social media") ||  m11, bylabel("Vote in municipal election") ||  m12, bylabel("Run for office") ///
						xline(0) xscale(r(-1 1)) drop(_cons age_sd 2.gender pol_interest) byopts(compact cols(4) scale(2))	xsize(6) ysize(2) coeflabels(, wrap(15) labcolor(black)) ///
						mlabposition(2) mlabgap(0.1pt) msymbol(circle) msize(medlarge) mcolor(gs9)  mlcolor(black) ciopts(recast(rspike) color(black) ) 						///
						mlabel(cond(@pval<.001, "***", ///
						cond(@pval<.01, "**",   ///
						cond(@pval<.05, "*", ""))))
				graph export all12.tif, replace // This is Figure 2 in the article
		
			
*Hypothesis 2: Exposure to online abuse of politicians decreases prospective political participation more among women than among men 
	reg political_participation 			i.random_some_comm##i.gender age_sd pol_interest // No significant interactions with gender, disconfirming H2
		eststo h2_main
	reg some_political_participation		i.random_some_comm##i.gender age_sd pol_interest // No significant interactions with gender, disconfirming H2
		eststo h2_so
	reg non_some_political_participation	i.random_some_comm##i.gender age_sd pol_interest // No significant interactions with gender, disconfirming H2
		eststo h2_no
	reg run_election						i.random_some_comm##i.gender age_sd pol_interest // No significant interactions with gender, disconfirming H2
		eststo h2_run
		
*Hypothesis 3: Exposure to online abuse of politicians decreases prospective political participation more among individuals with a high level of conflict avoidance than among individuals with a low level of conflict avoidance 
	sum conflict_avoidance if completed==2 , detail 
	local ca_low = `r(p5)'
	local ca_high= `r(p95)'
	reg political_participation 			i.random_some_comm##c.conflict_avoidance i.gender age_sd pol_interest // No significant interactions with conflict avoidance, disconfirming H3
	eststo h3_main
		margins, at(conflict_avoidance=(`ca_low' `ca_high')) post //conflict avoidance correlates with political participation, as expected
	reg some_political_participation		i.random_some_comm##c.conflict_avoidance i.gender age_sd pol_interest // No significant interactions with conflict avoidance, disconfirming H3
	eststo h3_so
	reg non_some_political_participation	i.random_some_comm##c.conflict_avoidance i.gender age_sd pol_interest // No significant interactions with conflict avoidance, disconfirming H3
	eststo h3_no
	reg run_election						i.random_some_comm##c.conflict_avoidance i.gender age_sd pol_interest // No significant interactions with conflict avoidance, disconfirming H3
	eststo h3_run
	
	*Exploratory: Conflict Avoidance and gender
	reg conflict_avoidance i.gender
	margins, over(gender) // Women have higher levels of conflict avoidance than men do
		
************
***Tables***
************
	
	esttab 	h1_main h1_so h1_no h1_run /// 
			using h1.rtf  ///
			, nobase se r2 b(2) label replace
			
	esttab 	h1_main_exp h1_main_exp2 h1_so_exp h1_so_exp2 h1_no_exp h1_no_exp2 h1_run_exp h1_run_exp2  /// 
			using h1_expl.rtf  ///
			, mgroups("Overall participation" "SoMe participation" "non-SoMe Pol Participation" "Running for election", pattern(1 0 1 0 1 0 1 0) ) ///
			nobase se r2  b(2) label replace
					
			
	esttab 	m1 m2 m3 m4 m5 m6  /// 
			using h1_supl1.rtf  ///
			, mtitles("Comments Facebook" "Share Facebook" "Like Facebook" "Write letter" "Write SoMe post" "Demonstrate"  ) ///
			nobase se r2  b(2) label replace
			
	esttab 	m7 m8 m9 m10 m11 m12  /// 
			using h1_supl2.rtf  ///
			, mtitles("Discuss privately" "Write to Newspaper" "Petition" "Discuss, SoMe" "Vote" "Run for election"  ) ///
			nobase se r2  b(2) label replace			
			
	esttab 	h2_main h2_so h2_no h2_run /// 
			using h2.rtf ///
			, mtitles("Overall participation" "SoMe participation" "non_SoNe_political_participation" "Running for election") ///
			nobase se r2  b(2) label replace
			
	esttab 	h3_main h3_so h3_no h3_run /// 
			using h3.rtf  ///
			, mtitles("Overall participation" "SoMe participation" "non-SoMe" "Running for election") ///
			nobase se r2  b(2) label replace
			
*************
***THE END***
*************		